package com.mj.common.sdk.api;



/**
 * 微信客户端工厂
 *  @author zhouping
 */
public class ClientFactory {

    /**
     * 构建获取全局access_token客户端
     * @param appId
     * @param appSecret
     * @return
     */
    public static AccessTokenClient createAccessTokenClient(String appId, String appSecret,String token ){
        ApiConfig apiConfig = new ApiConfig();
        apiConfig.init(appId, appSecret,token);
        return createAccessTokenClient(apiConfig);
    }

    /**
     * 构建获取全局access_token客户端
     * @param apiConfig
     * @return
     */
    public static AccessTokenClient createAccessTokenClient(ApiConfig apiConfig){
        AccessTokenClient accessTokenClient = new AccessTokenClient();
        return accessTokenClient.init(apiConfig);
    }


    /**
     * 构建微信菜单客户端
     * @param appId
     * @param appSecret
     * @return
     */
    public static MenuClient createMenuClient(String appId, String appSecret, String token ){
        ApiConfig apiConfig = new ApiConfig();
        apiConfig.init(appId, appSecret,token);
        return createMenuClient(apiConfig);
    }

    /**
     * 构建微信菜单客户端
     * @param apiConfig
     * @return
     */
    public static MenuClient createMenuClient(ApiConfig apiConfig){
        MenuClient menuClient = new MenuClient();
        return menuClient.init(apiConfig);
    }

    /**
     * 构建用户相关工具类
     * @param appId
     * @param appSecret
     * @return
     */
    public static UserClient createUserClient(String appId, String appSecret,String token ){
        ApiConfig apiConfig = new ApiConfig();
        apiConfig.init(appId, appSecret, token);
        return createUserClient(apiConfig);
    }

    /**
     * 构建用户相关工具类
     * @param apiConfig
     * @return
     */
    public static UserClient createUserClient(ApiConfig apiConfig){
        UserClient client = new UserClient();
        return client.init(apiConfig);
    }

    /**
     * 构建模版发送工具类
     * @param appId
     * @param appSecret
     * @param token
     * @return
     */
    public static MessageTemplateClient createMessageTemplateClient(String appId, String appSecret,String token ){
    	 ApiConfig apiConfig = new ApiConfig();
         apiConfig.init(appId, appSecret, token);
		return createMessageTemplateClient(apiConfig);
 	   
    }
    
    /**
     * 构建模版发送工具类
     * @param apiConfig
     * @return
     */
    public static MessageTemplateClient createMessageTemplateClient(ApiConfig apiConfig){
    	MessageTemplateClient client = new MessageTemplateClient();
        return client.init(apiConfig);
    }
    
    /**
     * 构建生成二维码工具
     * @param appId
     * @param appSecret
     * @param token
     * @return
     */
    public static QRcodeClient createQRcodeClient(String appId, String appSecret,String token ){
    	 ApiConfig apiConfig = new ApiConfig();
         apiConfig.init(appId, appSecret, token);
		return createQRcodeClient(apiConfig);
 	   
    }
    
    /**
     * 构建生成二维码工具
     * @param apiConfig
     * @return
     */
    public static QRcodeClient createQRcodeClient(ApiConfig apiConfig){
    	QRcodeClient client = new QRcodeClient();
        return client.init(apiConfig);
    }
    
    public static Oauth2GetOpenIdCilent createOauth2GetOpenIdCilent(String appId, String appSecret,String token ){
    	 ApiConfig apiConfig = new ApiConfig();
         apiConfig.init(appId, appSecret, token);
         return createOauth2GetOpenIdCilent(apiConfig);
    }

	private static Oauth2GetOpenIdCilent createOauth2GetOpenIdCilent(ApiConfig apiConfig) {
		Oauth2GetOpenIdCilent cilent = new Oauth2GetOpenIdCilent();	
		return cilent.init(apiConfig);
	}
    
	/**
	 * 客服发送消息
	 * @param appId
	 * @param appSecret
	 * @param token
	 * @return
	 */
	public static MessageCustomCilent createMessageCustomCilent(String appId, String appSecret,String token){
		 ApiConfig apiConfig = new ApiConfig();
         apiConfig.init(appId, appSecret, token);
		return createMessageCustomCilent(apiConfig);
	}
	
	/**
	 * 
	 * @param apiConfig
	 * @return
	 */
	public static MessageCustomCilent createMessageCustomCilent(ApiConfig apiConfig){
		MessageCustomCilent cilent = new MessageCustomCilent();
		return cilent.init(apiConfig);
	}
}
